﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ImageProcessing.DataEntryDialogs
{
    public partial class HistogramMatchingDialog : Form
    {
        private Bitmap inputImage;
        private Bitmap oldImage;
        private Bitmap resultedImage;

        public Bitmap ResultedImage
        {
            get
            {
                return this.resultedImage;
            }
        }

        public HistogramMatchingDialog(Bitmap image)
        {
            InitializeComponent();
            this.oldImage = image;
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            this.HistogramMatching();
        }

        public void HistogramMatching()
        {
            this.inputImage = (Bitmap)this.picBoxInput.Image;
            ImageEnhancement enhancement = new ImageEnhancement(this.oldImage);
            this.resultedImage = enhancement.HistogramMatching(this.inputImage, this.oldImage);
            this.Close();
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            try
            {
                PictureControl picControl = new PictureControl();
                this.picBoxInput.Image = (Image)picControl.OpenImage();
                this.btnApply.Enabled = true;

            }
            catch (Exception ex)
            {
                Utilities.Logger.LogException(ex);
                throw;
            }
        }
    }
}
